a blessing in disguise

Translations
un mal pour un bien
Definitions
A situation that appears to be negative or unfortunate at first, but ultimately results in something positive or beneficial.